<!DOCTYPE html>
<html>
<head>
    

    

    
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?a7c05ce530152d9866930ef4850ee566"></script>
<!-- End Baidu Tongji -->




    <meta charset="utf-8">
    
    
    
    <title>Redis集群 | 神奇的鸭鸭の码农库 | 新知识要不断的总结记录成笔记，要多写，多画，能够清晰透彻的将知识讲给别人听，才是达到理解的层次。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#765959">
    
    
    <meta name="keywords" content="缓存">
    <meta name="description" content="redis-cluster架构架构细节：  所有的redis节点彼此互联(PING-PONG机制)，内部使用二进制协议优化传输速度和带宽。 节点的fail是通过集群中超过半数的节点检测失效时才生效。 客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可。 redis-cluster把所有的物理节点映射到[0-16383]slot上,clu">
<meta name="keywords" content="缓存">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis集群">
<meta property="og:url" content="http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/index.html">
<meta property="og:site_name" content="神奇的鸭鸭の码农库">
<meta property="og:description" content="redis-cluster架构架构细节：  所有的redis节点彼此互联(PING-PONG机制)，内部使用二进制协议优化传输速度和带宽。 节点的fail是通过集群中超过半数的节点检测失效时才生效。 客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可。 redis-cluster把所有的物理节点映射到[0-16383]slot上,clu">
<meta property="og:image" content="http://om6odecqr.bkt.clouddn.com/redis-cluster%E6%9E%B6%E6%9E%84.png">
<meta property="og:image" content="http://om6odecqr.bkt.clouddn.com/redis%E5%93%88%E5%B8%8C%E6%A7%BD.png">
<meta property="og:image" content="http://om6odecqr.bkt.clouddn.com/redis%E5%93%88%E5%B8%8C%E6%A7%BD.png">
<meta property="og:updated_time" content="2017-12-05T09:59:16.714Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Redis集群">
<meta name="twitter:description" content="redis-cluster架构架构细节：  所有的redis节点彼此互联(PING-PONG机制)，内部使用二进制协议优化传输速度和带宽。 节点的fail是通过集群中超过半数的节点检测失效时才生效。 客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可。 redis-cluster把所有的物理节点映射到[0-16383]slot上,clu">
<meta name="twitter:image" content="http://om6odecqr.bkt.clouddn.com/redis-cluster%E6%9E%B6%E6%9E%84.png">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.4.3">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">神奇的鸭鸭</h5>
          <a href="mailto:702038338@qq.com" title="702038338@qq.com" class="mail">702038338@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/magic_duck" target="_blank" >
                <i class="icon icon-lg icon-gg-circle"></i>
                码云
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://www.zhihu.com/people/shen-qi-de-ya-ya" target="_blank" >
                <i class="icon icon-lg icon-twitter"></i>
                知乎
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404页面测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Redis集群</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">Redis集群</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-09-06T17:00:00.000Z" itemprop="datePublished" class="page-time">
  2017-09-07
</time>


            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#redis-cluster架构"><span class="post-toc-number">1.</span> <span class="post-toc-text">redis-cluster架构</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#redis-cluster投票：容错"><span class="post-toc-number">2.</span> <span class="post-toc-text">redis-cluster投票：容错</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#安装ruby"><span class="post-toc-number">3.</span> <span class="post-toc-text">安装ruby</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#搭建集群"><span class="post-toc-number">4.</span> <span class="post-toc-text">搭建集群</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#集群的一些命令"><span class="post-toc-number">5.</span> <span class="post-toc-text">集群的一些命令</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#维护节点"><span class="post-toc-number">6.</span> <span class="post-toc-text">维护节点</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#添加主节点"><span class="post-toc-number">6.1.</span> <span class="post-toc-text">添加主节点</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#添加从节点"><span class="post-toc-number">6.2.</span> <span class="post-toc-text">添加从节点</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#删除节点"><span class="post-toc-number">6.3.</span> <span class="post-toc-text">删除节点</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-redis4.4.0_primary_05"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">Redis集群</h1>
        <div class="post-meta">
            <time class="post-time" title="2017年09月07日 1:00" datetime="2017-09-06T17:00:00.000Z"  itemprop="datePublished">2017-09-07</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="redis-cluster架构"><a href="#redis-cluster架构" class="headerlink" title="redis-cluster架构"></a>redis-cluster架构</h2><p><img src="http://om6odecqr.bkt.clouddn.com/redis-cluster%E6%9E%B6%E6%9E%84.png" alt="redis-cluster架构"><br><strong>架构细节：</strong></p>
<ul>
<li>所有的redis节点彼此互联(<strong>PING-PONG机制</strong>)，内部使用二进制协议优化传输速度和带宽。</li>
<li>节点的fail是通过集群中<strong>超过半数的节点检测</strong>失效时才生效。</li>
<li>客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可。</li>
<li>redis-cluster把所有的物理节点映射到[0-16383]slot上,cluster 负责维护node&lt;-&gt;slot&lt;-&gt;value</li>
</ul>
<p>Redis 集群中内置了 16384 个哈希槽，当需要在 Redis 集群中放置一个 key-value 时，redis 先对 key 使用 crc16 算法算出一个结果，然后把结果对 16384 求余数，这样每个 key 都会对应一个编号在 0-16383 之间的哈希槽，redis 会根据节点数量大致均等的将哈希槽映射到不同的节点：<br><img src="http://om6odecqr.bkt.clouddn.com/redis%E5%93%88%E5%B8%8C%E6%A7%BD.png" alt="示例"></p>
<h2 id="redis-cluster投票：容错"><a href="#redis-cluster投票：容错" class="headerlink" title="redis-cluster投票：容错"></a>redis-cluster投票：容错</h2><p><img src="http://om6odecqr.bkt.clouddn.com/redis%E5%93%88%E5%B8%8C%E6%A7%BD.png" alt="redis-cluster投票-容错"></p>
<ul>
<li>集群中所有master参与投票,如果半数以上master节点与其中一个master节点通信超过(cluster-node-timeout),认为该master节点挂掉。</li>
<li>什么时候整个集群不可用(cluster_state:fail)? <ul>
<li>如果集群任意master挂掉,且当前master没有slave，则集群进入fail状态。也可以理解成集群的[0-16383]slot映射不完全时进入fail状态。</li>
<li>如果集群超过半数以上master挂掉，无论是否有slave，集群进入fail状态。</li>
</ul>
</li>
</ul>
<h2 id="安装ruby"><a href="#安装ruby" class="headerlink" title="安装ruby"></a>安装ruby</h2><p>集群管理工具(redis-trib.rb)是使用ruby脚本语言编写的，所以先安装Ruby，具体安装过程可以参考网上教程，本文给出粗略安装过程：<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span> 建议先安装RVM http://www.rvm.io/</div><div class="line">gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB</div><div class="line">\curl -sSL https://get.rvm.io | bash -s stable</div><div class="line">source ~/.bashrc</div><div class="line">source ~/.bash_profile</div><div class="line"></div><div class="line"><span class="meta">#</span> 列出已知Ruby版本</div><div class="line">rvm list known</div><div class="line"></div><div class="line"><span class="meta">#</span> 切换Ruby版本</div><div class="line">rvm use 2.4.0</div><div class="line"></div><div class="line"><span class="meta">#</span> 如果想设置为默认版本，这样一来以后新打开的控制台默认的 Ruby 就是这个版本</div><div class="line">rvm use 2.4.0 --default </div><div class="line"></div><div class="line"><span class="meta">#</span> 查询已经安装的ruby</div><div class="line">rvm list</div><div class="line"></div><div class="line"><span class="meta">#</span> 安装ruby和redis接口redis-4.0.0.gem https://rubygems.org/gems/redis</div><div class="line">gem install redis-4.0.0.gem</div><div class="line"></div><div class="line"><span class="meta">#</span> 将redis-4.0.1/src目录中的redis-trib.rb(Redis集群搭建脚本文件)拷贝到redis-4.0.1/redis-cluster</div><div class="line">[root@VM_122_1_centos src]# mkdir /usr/local/redis-4.0.1/redis-cluster</div><div class="line">[root@VM_122_1_centos src]# cp redis-trib.rb /usr/local/redis-4.0.1/redis-cluster/</div></pre></td></tr></table></figure></p>
<h2 id="搭建集群"><a href="#搭建集群" class="headerlink" title="搭建集群"></a>搭建集群</h2><p>搭建集群最少也需要3台主机，如果每台主机再配置一台从机，则最少需要6台机器，于是端口设计为7001-7006</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span> 第一步，先复制出一个7001机器</div><div class="line">[root@VM_122_1_centos redis-4.0.1]# cp bin ./redis-cluster/7001 -r</div><div class="line"></div><div class="line"><span class="meta">#</span> 第二步：如果存在持久化文件，则删除</div><div class="line">[root@VM_122_1_centos 7001]# ls</div><div class="line">appendonly.aof  redis-benchmark  redis-check-rdb  redis.conf      redis-server</div><div class="line">dump.rdb        redis-check-aof  redis-cli        redis-sentinel</div><div class="line">[root@VM_122_1_centos 7001]# rm -rf appendonly.aof dump.rdb </div><div class="line"></div><div class="line"><span class="meta">#</span> 第三步：开启集群参数-修改端口</div><div class="line">cluster-enabled yes</div><div class="line">port 7001</div><div class="line"></div><div class="line"><span class="meta">#</span> 第四步 依次复制出7002-7006机器</div><div class="line">[root@VM_122_1_centos redis-cluster]# cp 7001/ 7002 -r</div><div class="line">[root@VM_122_1_centos redis-cluster]# cp 7001/ 7003 -r</div><div class="line">[root@VM_122_1_centos redis-cluster]# cp 7001/ 7004 -r</div><div class="line">[root@VM_122_1_centos redis-cluster]# cp 7001/ 7005 -r</div><div class="line">[root@VM_122_1_centos redis-cluster]# cp 7001/ 7006 -r</div><div class="line">[root@VM_122_1_centos redis-cluster]# ls</div><div class="line">7001  7002  7003  7004  7005  7006  redis-trib.rb</div><div class="line"></div><div class="line"><span class="meta">#</span> 第五步 修改7002-7006的端口</div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7002/redis.conf </div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7002/redis.conf </div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7003/redis.conf </div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7004/redis.conf </div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7005/redis.conf </div><div class="line">[root@VM_122_1_centos redis-cluster]# vim 7006/redis.conf </div><div class="line"></div><div class="line"><span class="meta">#</span> 第六步 启动7001-7006这六台机器，建议写成脚本：</div><div class="line">[root@VM_122_1_centos redis-cluster]# vim start-all.sh</div><div class="line">cd 7001</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">cd 7002</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">cd 7003</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">cd 7004</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">cd 7005</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">cd 7006</div><div class="line">./redis-server redis.conf</div><div class="line">cd ..</div><div class="line">[root@VM_122_1_centos redis-cluster]# chmod u+x start-all.sh </div><div class="line">[root@VM_122_1_centos redis-cluster]# ./start-all.sh </div><div class="line"></div><div class="line"><span class="meta">#</span> 第七步 检查服务器是否都开启</div><div class="line">[root@VM_122_1_centos redis-cluster]# ps -aux |grep redis</div><div class="line">root      6860  0.0  0.9 147292  9280 ?        Ssl  10:55   0:10 ./redis-server 0.0.0.0:6380</div><div class="line">root      6919  0.0  0.9 147292  9352 ?        Ssl  10:56   0:10 ./redis-server 0.0.0.0:6379</div><div class="line">root     21543  0.1  0.2 147296  2752 ?        Ssl  14:29   0:00 ./redis-server 0.0.0.0:7001 [cluster]</div><div class="line">root     21545  0.0  0.2 147296  2752 ?        Rsl  14:29   0:00 ./redis-server 0.0.0.0:7002 [cluster]</div><div class="line">root     21547  0.0  0.2 147296  2756 ?        Rsl  14:29   0:00 ./redis-server 0.0.0.0:7003 [cluster]</div><div class="line">root     21549  0.0  0.2 147296  2760 ?        Rsl  14:29   0:00 ./redis-server 0.0.0.0:7004 [cluster]</div><div class="line">root     21551  0.0  0.2 147296  2756 ?        Rsl  14:29   0:00 ./redis-server 0.0.0.0:7005 [cluster]</div><div class="line">root     21553  0.0  0.2 147296  2748 ?        Ssl  14:29   0:00 ./redis-server 0.0.0.0:7006 [cluster]</div><div class="line"></div><div class="line"><span class="meta">#</span> 第八步 创建集群 启动集群管理 记得开启腾讯云安全组</div><div class="line">[root@VM_122_1_centos redis-cluster]# ./redis-trib.rb create --replicas 1 118.89.59.106:7001 118.89.59.106:7002 118.89.59.106:7003 118.89.59.106:7004 118.89.59.106:7005  118.89.59.106:7006</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Creating cluster</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Performing hash slots allocation on 6 nodes...</div><div class="line">Using 3 masters:</div><div class="line">118.89.59.106:7001</div><div class="line">118.89.59.106:7002</div><div class="line">118.89.59.106:7003</div><div class="line">Adding replica 118.89.59.106:7004 to 118.89.59.106:7001</div><div class="line">Adding replica 118.89.59.106:7005 to 118.89.59.106:7002</div><div class="line">Adding replica 118.89.59.106:7006 to 118.89.59.106:7003</div><div class="line">M: e0b31a7d43ec9ee51d9010089b14f69804e58b87 118.89.59.106:7001</div><div class="line">   slots:0-5460 (5461 slots) master</div><div class="line">M: 77245b8838cddc7a5d999bea8d3775b86cc69fa1 118.89.59.106:7002</div><div class="line">   slots:5461-10922 (5462 slots) master</div><div class="line">M: 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 118.89.59.106:7003</div><div class="line">   slots:10923-16383 (5461 slots) master</div><div class="line">S: 19995ea3e2c899387508d6d5d419e26e6d00507d 118.89.59.106:7004</div><div class="line">   replicates e0b31a7d43ec9ee51d9010089b14f69804e58b87</div><div class="line">S: ff7ad28a2ec7bb651e3f053d1130628df7d21992 118.89.59.106:7005</div><div class="line">   replicates 77245b8838cddc7a5d999bea8d3775b86cc69fa1</div><div class="line">S: 71bf08c7f6b28bc8b653e5dbe7efce7b964731a5 118.89.59.106:7006</div><div class="line">   replicates 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9</div><div class="line"></div><div class="line">Can I set the above configuration? (type 'yes' to accept): yes</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Nodes configuration updated</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Assign a different config epoch to each node</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Sending CLUSTER MEET messages to join the cluster</div><div class="line">Waiting for the cluster to join.........</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Performing Cluster Check (using node 118.89.59.106:7001)</div><div class="line">M: e0b31a7d43ec9ee51d9010089b14f69804e58b87 118.89.59.106:7001</div><div class="line">   slots:0-5460 (5461 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">S: 19995ea3e2c899387508d6d5d419e26e6d00507d 118.89.59.106:7004</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates e0b31a7d43ec9ee51d9010089b14f69804e58b87</div><div class="line">S: 71bf08c7f6b28bc8b653e5dbe7efce7b964731a5 118.89.59.106:7006</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9</div><div class="line">M: 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 118.89.59.106:7003</div><div class="line">   slots:10923-16383 (5461 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">S: ff7ad28a2ec7bb651e3f053d1130628df7d21992 118.89.59.106:7005</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates 77245b8838cddc7a5d999bea8d3775b86cc69fa1</div><div class="line">M: 77245b8838cddc7a5d999bea8d3775b86cc69fa1 118.89.59.106:7002</div><div class="line">   slots:5461-10922 (5462 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">[OK] All nodes agree about slots configuration.</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Check for open slots...</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Check slots coverage...</div><div class="line">[OK] All 16384 slots covered.</div><div class="line"></div><div class="line"><span class="meta">#</span> 测试连接集群 注意端口变化</div><div class="line">[root@VM_122_1_centos 7001]# ./redis-cli -h 118.89.59.106 -p 7001 -c</div><div class="line">118.89.59.106:7001&gt; set s1 111</div><div class="line"><span class="meta">-&gt;</span> Redirected to slot [15224] located at 118.89.59.106:7003</div><div class="line">OK</div><div class="line">118.89.59.106:7003&gt; </div><div class="line"></div><div class="line"><span class="meta">#</span> 测试集群关系</div><div class="line"><span class="meta">#</span># 先kill掉7002</div><div class="line">[root@VM_122_1_centos 7001]# kill -9 21545</div><div class="line">[root@VM_122_1_centos 7001]# ps -aux |grep redis</div><div class="line">root      6860  0.0  0.9 147292  9280 ?        Ssl  10:55   0:11 ./redis-server 0.0.0.0:6380</div><div class="line">root      6919  0.0  0.9 147292  9352 ?        Ssl  10:56   0:10 ./redis-server 0.0.0.0:6379</div><div class="line">root     21543  0.0  0.3 149344  3260 ?        Ssl  14:29   0:01 ./redis-server 0.0.0.0:7001 [cluster]</div><div class="line">root     21547  0.0  0.3 149344  3292 ?        Ssl  14:29   0:01 ./redis-server 0.0.0.0:7003 [cluster]</div><div class="line">root     21549  0.1  0.3 149344  3168 ?        Ssl  14:29   0:01 ./redis-server 0.0.0.0:7004 [cluster]</div><div class="line">root     21551  0.0  0.3 149344  3172 ?        Ssl  14:29   0:01 ./redis-server 0.0.0.0:7005 [cluster]</div><div class="line">root     21553  0.0  0.3 149344  3180 ?        Ssl  14:29   0:01 ./redis-server 0.0.0.0:7006 [cluster]</div><div class="line"></div><div class="line"><span class="meta">#</span># 查看集群节点状况 注意7002已经fail，而7005slave已经上位成为master！</div><div class="line">118.89.59.106:7001&gt; cluster nodes</div><div class="line">19995ea3e2c899387508d6d5d419e26e6d00507d 118.89.59.106:7004@17004 slave e0b31a7d43ec9ee51d9010089b14f69804e58b87 0 1504767087000 4 connected</div><div class="line">e0b31a7d43ec9ee51d9010089b14f69804e58b87 10.135.122.1:7001@17001 myself,master - 0 1504767085000 1 connected 0-5460</div><div class="line">71bf08c7f6b28bc8b653e5dbe7efce7b964731a5 118.89.59.106:7006@17006 slave 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 0 1504767088176 6 connected</div><div class="line">2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 118.89.59.106:7003@17003 master - 0 1504767089179 3 connected 10923-16383</div><div class="line">ff7ad28a2ec7bb651e3f053d1130628df7d21992 118.89.59.106:7005@17005 master - 0 1504767088000 8 connected 5461-10922</div><div class="line">77245b8838cddc7a5d999bea8d3775b86cc69fa1 118.89.59.106:7002@17002 master,fail - 1504766972257 1504766970756 2 disconnected</div><div class="line"></div><div class="line"><span class="meta">#</span># 接下来我们复活7002 </div><div class="line">[root@VM_122_1_centos 7002]# ./redis-server redis.conf </div><div class="line"></div><div class="line"><span class="meta">#</span># 可以发现7002已经沦为slave</div><div class="line">118.89.59.106:7001&gt; cluster nodes</div><div class="line">19995ea3e2c899387508d6d5d419e26e6d00507d 118.89.59.106:7004@17004 slave e0b31a7d43ec9ee51d9010089b14f69804e58b87 0 1504767808000 4 connected</div><div class="line">e0b31a7d43ec9ee51d9010089b14f69804e58b87 10.135.122.1:7001@17001 myself,master - 0 1504767806000 1 connected 0-5460</div><div class="line">71bf08c7f6b28bc8b653e5dbe7efce7b964731a5 118.89.59.106:7006@17006 slave 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 0 1504767807864 6 connected</div><div class="line">2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 118.89.59.106:7003@17003 master - 0 1504767806000 3 connected 10923-16383</div><div class="line">ff7ad28a2ec7bb651e3f053d1130628df7d21992 118.89.59.106:7005@17005 master - 0 1504767807000 8 connected 5461-10922</div><div class="line">77245b8838cddc7a5d999bea8d3775b86cc69fa1 118.89.59.106:7002@17002 slave ff7ad28a2ec7bb651e3f053d1130628df7d21992 0 1504767808868 8 connected</div></pre></td></tr></table></figure>
<h2 id="集群的一些命令"><a href="#集群的一些命令" class="headerlink" title="集群的一些命令"></a>集群的一些命令</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span> 查看集群状态</div><div class="line">118.89.59.106:7003&gt; cluster info</div><div class="line">cluster_state:ok</div><div class="line">cluster_slots_assigned:16384</div><div class="line">cluster_slots_ok:16384</div><div class="line">cluster_slots_pfail:0</div><div class="line">cluster_slots_fail:0</div><div class="line">cluster_known_nodes:6</div><div class="line">cluster_size:3</div><div class="line">cluster_current_epoch:6</div><div class="line">cluster_my_epoch:3</div><div class="line">cluster_stats_messages_ping_sent:467</div><div class="line">cluster_stats_messages_pong_sent:492</div><div class="line">cluster_stats_messages_meet_sent:2</div><div class="line">cluster_stats_messages_sent:961</div><div class="line">cluster_stats_messages_ping_received:489</div><div class="line">cluster_stats_messages_pong_received:469</div><div class="line">cluster_stats_messages_meet_received:3</div><div class="line">cluster_stats_messages_received:961</div><div class="line"></div><div class="line"><span class="meta">#</span> 查看集群中的节点 可以看到从机是没有槽的</div><div class="line">118.89.59.106:7003&gt; cluster nodes</div><div class="line">ff7ad28a2ec7bb651e3f053d1130628df7d21992 118.89.59.106:7005@17005 slave 77245b8838cddc7a5d999bea8d3775b86cc69fa1 0 1504766804403 5 connected</div><div class="line">19995ea3e2c899387508d6d5d419e26e6d00507d 118.89.59.106:7004@17004 slave e0b31a7d43ec9ee51d9010089b14f69804e58b87 0 1504766805404 4 connected</div><div class="line">71bf08c7f6b28bc8b653e5dbe7efce7b964731a5 118.89.59.106:7006@17006 slave 2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 0 1504766803000 6 connected</div><div class="line">77245b8838cddc7a5d999bea8d3775b86cc69fa1 118.89.59.106:7002@17002 master - 0 1504766806000 2 connected 5461-10922</div><div class="line">2af9b2c3c2bbd4bff82d10454db4fe990c0369a9 10.135.122.1:7003@17003 myself,master - 0 1504766805000 3 connected 10923-16383</div><div class="line">e0b31a7d43ec9ee51d9010089b14f69804e58b87 118.89.59.106:7001@17001 master - 0 1504766806407 1 connected 0-5460</div></pre></td></tr></table></figure>
<h2 id="维护节点"><a href="#维护节点" class="headerlink" title="维护节点"></a>维护节点</h2><h3 id="添加主节点"><a href="#添加主节点" class="headerlink" title="添加主节点"></a>添加主节点</h3><p>集群创建成功后可以向集群中添加节点，下面是添加一个master主节点<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span> 添加7007节点作为新节点</div><div class="line">[root@VM_122_1_centos redis-cluster]# ./redis-trib.rb add-node 118.89.59.106:7007 118.89.59.106:7001</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Adding node 118.89.59.106:7007 to cluster 118.89.59.106:7001</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Performing Cluster Check (using node 118.89.59.106:7001)</div><div class="line">M: 4fa329228c9ad693f992181afd161c89f7375968 118.89.59.106:7001</div><div class="line">   slots:0-5460 (5461 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">S: d948117bdbaa085e900dee9bac6cd9b3c5cb5aae 118.89.59.106:7006</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates 83588ff1de0c0067670d3e4cf0fb1551d449f699</div><div class="line">M: 83588ff1de0c0067670d3e4cf0fb1551d449f699 118.89.59.106:7003</div><div class="line">   slots:10923-16383 (5461 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">S: 8451ffff42527ac3b38e6248cc1455085da73786 118.89.59.106:7005</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates d63a45b812201035535a8293023ca9801131cfb4</div><div class="line">M: d63a45b812201035535a8293023ca9801131cfb4 118.89.59.106:7002</div><div class="line">   slots:5461-10922 (5462 slots) master</div><div class="line">   1 additional replica(s)</div><div class="line">S: b782d83285766130db92691c46a842e20140dc64 118.89.59.106:7004</div><div class="line">   slots: (0 slots) slave</div><div class="line">   replicates 4fa329228c9ad693f992181afd161c89f7375968</div><div class="line">[OK] All nodes agree about slots configuration.</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Check for open slots...</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Check slots coverage...</div><div class="line">[OK] All 16384 slots covered.</div><div class="line"><span class="meta">&gt;</span>&gt;&gt; Send CLUSTER MEET to node 118.89.59.106:7007 to make it join the cluster.</div><div class="line">[OK] New node added correctly.</div><div class="line"></div><div class="line"><span class="meta">#</span> 查看集群中槽占用情况</div><div class="line">118.89.59.106:7007&gt; cluster nodes</div><div class="line">d63a45b812201035535a8293023ca9801131cfb4 118.89.59.106:7002@17002 master - 0 1504771105784 2 connected 5461-10922</div><div class="line">d948117bdbaa085e900dee9bac6cd9b3c5cb5aae 118.89.59.106:7006@17006 slave 83588ff1de0c0067670d3e4cf0fb1551d449f699 0 1504771106000 3 connected</div><div class="line">4fa329228c9ad693f992181afd161c89f7375968 118.89.59.106:7001@17001 master - 0 1504771106787 1 connected 0-5460</div><div class="line">8451ffff42527ac3b38e6248cc1455085da73786 118.89.59.106:7005@17005 slave d63a45b812201035535a8293023ca9801131cfb4 0 1504771102000 2 connected</div><div class="line">83588ff1de0c0067670d3e4cf0fb1551d449f699 118.89.59.106:7003@17003 master - 0 1504771104000 3 connected 10923-16383</div><div class="line">065c9c2223949e77f407d20aefa6408aa1bcd181 10.135.122.1:7007@17007 myself,master - 0 1504771104000 0 connected</div><div class="line">b782d83285766130db92691c46a842e20140dc64 118.89.59.106:7004@17004 slave 4fa329228c9ad693f992181afd161c89f7375968 0 1504771105000 1 connected</div></pre></td></tr></table></figure></p>
<p><strong>添加完节点后需要对主节点7007进行hash槽分配，这样改主节点才可以存储数据：</strong><br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span> 给刚添加的7007结点分配槽</div><div class="line"><span class="meta">#</span># 第一步：连接上集群（连接集群中任意一个可用结点都行）</div><div class="line">[root@VM_122_1_centos redis-cluster]# ./redis-trib.rb reshard 118.89.59.106:7001</div><div class="line"></div><div class="line"><span class="meta">#</span># 第二步：输入要分配的槽数量（输入：500，表示要分配500个槽）</div><div class="line">How many slots do you want to move (from 1 to 16384)? 500</div><div class="line"></div><div class="line"><span class="meta">#</span># 第三步：输入接收槽的结点id 7007的ID是：065c9c2223949e77f407d20aefa6408aa1bcd181</div><div class="line">What is the receiving node ID? 065c9c2223949e77f407d20aefa6408aa1bcd181</div><div class="line"></div><div class="line"><span class="meta">#</span># 第四步：输入源结点id（槽点会从源节点中拿，输入all从所有源节点中获取槽，输入done取消分配）</div><div class="line">Please enter all the source node IDs.</div><div class="line">  Type 'all' to use all the nodes as source nodes for the hash slots.</div><div class="line">  Type 'done' once you entered all the source nodes IDs.</div><div class="line">Source node #1:all</div><div class="line"></div><div class="line"><span class="meta">#</span># 输入yes开始移动槽到目标结点id</div><div class="line">Do you want to proceed with the proposed reshard plan (yes/no)? yes</div><div class="line"></div><div class="line"></div><div class="line"><span class="meta">#</span> 查看集群中槽占用情况</div><div class="line">118.89.59.106:7007&gt; cluster nodes</div><div class="line">d63a45b812201035535a8293023ca9801131cfb4 118.89.59.106:7002@17002 master - 0 1504771392625 2 connected 5628-10922</div><div class="line">d948117bdbaa085e900dee9bac6cd9b3c5cb5aae 118.89.59.106:7006@17006 slave 83588ff1de0c0067670d3e4cf0fb1551d449f699 0 1504771389617 3 connected</div><div class="line">4fa329228c9ad693f992181afd161c89f7375968 118.89.59.106:7001@17001 master - 0 1504771390000 1 connected 166-5460</div><div class="line">8451ffff42527ac3b38e6248cc1455085da73786 118.89.59.106:7005@17005 slave d63a45b812201035535a8293023ca9801131cfb4 0 1504771391623 2 connected</div><div class="line">83588ff1de0c0067670d3e4cf0fb1551d449f699 118.89.59.106:7003@17003 master - 0 1504771390000 3 connected 11089-16383</div><div class="line">065c9c2223949e77f407d20aefa6408aa1bcd181 10.135.122.1:7007@17007 myself,master - 0 1504771392000 7 connected 0-165 5461-5627 10923-11088</div><div class="line">b782d83285766130db92691c46a842e20140dc64 118.89.59.106:7004@17004 slave 4fa329228c9ad693f992181afd161c89f7375968 0 1504771390618 1 connected</div></pre></td></tr></table></figure></p>
<h3 id="添加从节点"><a href="#添加从节点" class="headerlink" title="添加从节点"></a>添加从节点</h3><p>集群创建成功后可以向集群中添加节点，命令：<strong>./redis-trib.rb add-node –slave –master-id 主节点id 新节点的ip和端口 旧节点ip和端口</strong></p>
<p>注意：如果原来该结点在集群中的配置信息已经生成到cluster-config-file指定的配置文件中（如果cluster-config-file没有指定则默认为nodes.conf），这时可能会报错：<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[ERR] Node XXXXXX is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0</div></pre></td></tr></table></figure></p>
<p><strong>解决方法是删除生成的配置文件nodes.conf，删除后再执行./redis-trib.rb add-node指令</strong></p>
<h3 id="删除节点"><a href="#删除节点" class="headerlink" title="删除节点"></a>删除节点</h3><p>命令：<strong>./redis-trib.rb del-node 删除节点的ip和端口 删除节点id</strong></p>
<p>注意：删除已经占有hash槽的结点会失败，报错如下：<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[ERR] Node 127.0.0.1:7005 is not empty! Reshard data away and try again.</div></pre></td></tr></table></figure></p>
<p><strong>解决办法是需要将该结点占用的hash槽分配出去</strong></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-12-05T09:59:16.714Z" itemprop="dateUpdated">2017年12月5日 17:59</time>
</span><br>


        如要转载请注明出处：<a href="/2017/09/07/redis4.4.0_primary_05/" target="_blank" rel="external">http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/</a>
    </div>
    <footer>
        <a href="http://magic_duck.oschina.io">
            <img src="/img/avatar.jpg" alt="神奇的鸭鸭">
            神奇的鸭鸭
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/缓存/">缓存</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&title=《Redis集群》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&title=《Redis集群》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Redis集群》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/09/07/redis4.4.0_primary_06/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Jedis连接Reis集群</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/09/06/redis4.4.0_primary_04/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">Redis的主从复制</h4>
      </a>
    </div>
  
</nav>



    







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        我只要一角钱~ ~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.png" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://git.oschina.net/z77z" target="_blank">邹海清</a></span>
            <span>神奇的鸭鸭の码农库 &copy; 2017</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&title=《Redis集群》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&title=《Redis集群》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Redis集群》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://magic_duck.oschina.io/2017/09/07/redis4.4.0_primary_05/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



lazyScripts.push('//s95.cnzz.com/z_stat.php?id=1261081671&web_id=1261081671')

</script>

<script src="/js/main.min.js?v=1.4.3"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.4.3" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


</body>
</html>
